package com.fone.player.view;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnKeyListener;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import com.fone.player.R;
import com.fone.player.util.FoneUtil;

public class WaitingDialog {

	private static final String TAG = "ChangeUserNameDialog";

	private CustomDialog dialog;

	public WaitingDialog(final Context mContext, Activity activity) {
		View waitingView = LayoutInflater.from(mContext).inflate(
				R.layout.com_waiting_dialog, null);
//		animation = AnimationUtils.loadAnimation(mContext,
//				R.anim.progress_round);
//		progressbar = (ImageView) waitingView.findViewById(R.id.play_loading);
//		progressbar.setAnimation(animation);

		dialog = new CustomDialog((Context) activity, waitingView);
		dialog.setCanceledOnTouchOutside(false);
		dialog.setCancelable(false);
		dialog.setOnKeyListener(new OnKeyListener() {
			
			@Override
			public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
				if(keyCode==KeyEvent.KEYCODE_BACK){
					FoneUtil.showToast(mContext, "正在操作中,请稍候..");
				}
				return false;
				
			}
		});

	}

	public void showWaitingDialog() {
		dialog.show();
//		progressbar.startAnimation(animation);
	}

	public void cancelWaitingDialog() {
		dialog.cancel();
	}

	
}
